<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<style>
  body {
    margin: 0;
  }
  div {
    height: 2000px;
  }
</style>
<div></div>
<a id="anchor"></a>
<script>
  addEventListener('load', () => {
    document.getElementById("anchor").scrollIntoView();
    const max_scroll_offset =
        document.scrollingElement.scrollHeight -
        document.scrollingElement.clientHeight;
    test(() => {
      assert_equals(document.scrollingElement.scrollTop, max_scroll_offset);
    },
    "ScrollIntoView on empty anchor at end of document should scroll to end.");
  });
</script>
